//
//  RGMessageBaseCell.m
//  RedGrass
//
//  Created by wuyine on 2018/12/6.
//  Copyright © 2018年 hongcaosp. All rights reserved.
//

#import "RGMessageBaseCell.h"

@interface RGMessageBaseCell()
@end

@implementation RGMessageBaseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.contentView.backgroundColor = [UIColor blackColor];
        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
        [self initUI];
        [self addMasonry];
    }
    return self;
}

-(void) initUI{
    [self.contentView addSubview:self.userIcon];
    [self.contentView addSubview:self.userName];
    [self.contentView addSubview:self.contentLabel];
    [self.contentView addSubview:self.dateLabel];
}

-(void) addMasonry{
    [_userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(58, 58));
        make.left.mas_equalTo(self.contentView).mas_offset(15);
        make.centerY.mas_equalTo(self.contentView).mas_offset(0);
    }];
    
    [_userName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(_userIcon.mas_trailing).offset(10);
        make.top.equalTo(_userIcon.mas_top).offset(-1);
    }];
    
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(_userName.mas_leading);
        make.centerY.equalTo(_userIcon.mas_centerY);
    }];
    
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_userIcon.mas_bottom);
        make.leading.equalTo(_userName.mas_leading);
    }];
}

#pragma mark - getter
-(UIImageView *)userIcon{
    if(!_userIcon){
        _userIcon = [[UIImageView alloc]init];
        _userIcon.image = IMAGE_NAMED(@"头像1");
        ViewRadius(_userIcon, 25);
    }
    return _userIcon;
}

- (UILabel *)userName {
    if (!_userName) {
        _userName = [[UILabel alloc] init];
        _userName.font = FONT(customFontName, 15);
        _userName.textColor = UICOLOR_WITH_RGBINT(0xffffff);
//        _userName.text = @"用户名";
    }
    return _userName;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = FONT(customFontName, 13);
        _contentLabel.textColor = UICOLOR_WITH_RGBINT(0x999999);
//        _contentLabel.text = @"关注了你";
    }
    return _contentLabel;
}

- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.font = FONT(customFontName, 13);
        _dateLabel.textColor = UICOLOR_WITH_RGBINT(0x999999);
//        _dateLabel.text = @"06-06";
    }
    return _dateLabel;
}

@end
